ACSEventAdmin (version $Id: ACSEventAdmin.py,v 1.11 2006/12/22 23:34:43 sharring Exp $)
index
/diska/alma_tmp/ACS/LGPL/CommonSoftware/acspy/src/ACSEventAdmin.py

Python script which starts the ACS Event Browser. The only requirement for the
GUI to run is that the ACS Manager is up and running.
 
TODO:
- provide some sort of sorting mechanism to filter the events within the GUI...
- provide a better exit command to run
- This CVS module probably is not the best place for this package...
- Modular test!

 
Modules
       
CosNotification
Acspy.Util.NameTree
Tkinter
acscommon
acsnc
signal

 
Classes
       
Acspy.Clients.SimpleClient.PySimpleClient(Acspy.Clients.BaseClient.BaseClient, Acspy.Servants.ContainerServices.ContainerServices)
ACSEventAdmin
Acspy.Nc.Consumer.Consumer(CosNotifyComm__POA.StructuredPushConsumer, Acspy.Nc.CommonNC.CommonNC)
AdminConsumer

 
class ACSEventAdmin(Acspy.Clients.SimpleClient.PySimpleClient)
    This class is basically the back-end of the GUI and does all the hard work:
- finding channels
- dynamically creating consumers for the channels
- keeping track of events
- etc.
 
 
Method resolution order:
ACSEventAdmin
Acspy.Clients.SimpleClient.PySimpleClient
Acspy.Clients.BaseClient.BaseClient
maci__POA.Client
omniORB.PortableServer.Servant
Acspy.Servants.ContainerServices.ContainerServices

Methods defined here:
__init__(self, name='ACS Event Admin Client')
Just call superclass constructors here.
addChannel(self, channelName)
Method adds an AdminConsumer for the channel if it is not already registered
with this component.
 
Parameters:
- channelName is the name of a channel registered with the Naming Service
 
Returns: Nothing
 
Raises: ???
configChannelProperties(self, channelName, newQOS, newAdmin)
Python implementation of IDL method.
void configChannelProperties(in string channelName,
                             in CosNotification::QoSProperties newQOS,
                             in CosNotification::AdminProperties newAdmin);
createChannel(self, channelName, initialQOS, initialAdmin)
Python implementation of IDL method.
void createChannel(in string channelName,
                   in CosNotification::QoSProperties initialQOS,
                   in CosNotification::AdminProperties initialAdmin);
destroyChannel(self, channelName)
Python implementation of IDL method.
void destroyChannel(in string channelName);
disconnect(self)
Override this method.
getActiveChannels(self)
Python implementation of IDL method.
NCSeq getActiveChannels();
getChannelInfo(self, channelName)
Python implementation of IDL method.
void getChannelInfo(in string channelName, 
                    out unsigned short numSuppliers,
                    out unsigned short numConsumers,
                    out unsigned long long totalEvents,
                    out CosNotification::QoSProperties initialQOS,
                    out CosNotification::AdminProperties initialAdmin);
monitorEvents(self, cb, desc)
Python implementation of IDL method.
void monitorEvents(in ACS::CBstring cb,
                   in ACS::CBDescIn desc);
pollNamingService(self)
This method is designed to be run as a thread. All it does is constantly
poll the naming service looking for new Notification Channels. Once a new
channel is found, a new AdminConsumer is created.
 
Parameters: None
 
Returns: Nothing...this method is designed to be a separate thread
 
Raises: ???

Static methods inherited from Acspy.Clients.SimpleClient.PySimpleClient:
getInstance(name='PySingletonClient')
Returns a singleton instance of the PySimpleClient class.
 
Parameters:
- name is what manager will refer to this client singleton instance as
 
Returns: Nothing
 
Raises: CORBAProblemExImpl

Methods inherited from Acspy.Clients.BaseClient.BaseClient:
authenticate(self, execution_id, question)
Authentication method. Method authenticate is the challenge issued to
the client after it tries to login. The login will be successful if the
clients authenticate() produces the expected result. Only in this case
will the Managers login method return a valid handle, which the client
will later use as the id parameter with all calls to the Manager.
 
Parameters: question this string does not currently matter
 
Return Answer - first character of the answer identifies the type of
the client, and can be one of:
- C = a regular client (implements just the Client interface).
- A = a container (implements the Container interface).
- AR = a container with recovery capability (implements the Container interface).
- S = Supervisor (implements the Administrator interface).
 
Raises: Nothing
 
string authenticate (in string question);
components_available(self, components)
Notify client about the change (availability) of the components currently
in use by this client. For administrative clients, notification is issued
for the change of availability of any component in the domain.
 
Parameters:
- components is a sequence of ComponentInfo structures
 
Returns: None
 
Raises: Nothing
 
oneway void components_available(in ComponentInfoSeq components)
components_unavailable(self, component_names)
Notify client that some of the Components currently in use by client
have become unavailable.
 
Parameters:
- component_names names of various unavailable components
 
Returns: None
 
Raises: Nothing
 
oneway void Compoents_unavailable (in stringSeq component_names)
getCode(self)
Returns the code to be used when manager tries to authenticate this
object
 
Parameters: None
 
Returns: the code to be returned to manager.
 
Raises: Nothing
getMyCorbaRef(self)
Helper method which returns this Python objects underlying CORBA servant
reference.
 
This implementation implicityly activates the client using the default
POA if it has not been activated before.
 
Parameters: None
 
Returns: a CORBA reference to this object
 
Raises: CORBAProblemExImpl
message(self, message_type, message)
The Manager and administrators use this method for sending textual messages
to the client.
 
This implementation first attempts to use the ACS logging mechanism to
display the message and if that fails for any reason, it is only sent
to standard out.
 
Parameters:
- message_type is an integer defined as a constant in the Client interface
- message is a string
 
Returns: Nothing
 
Raises: Nothing
 
oneway void message (in short message_type, in string message)
ping(self)
Manager pings its clients to verify they still exist.
 
Parameters: None
 
Returns: CORBA.TRUE (i.e., 1)
 
Raises: Nothing
 
boolean ping ();

Methods inherited from Acspy.Servants.ContainerServices.ContainerServices:
activateOffShoot(self, py_obj)
Activates an OffShoot derived object as a CORBA object.
 
Parameters:
- py_obj is (non-CORBA) Python object.
 
Return: a reference to the CORBA object that almost definitely needs to
be narrowed to the correct type.  If anything goes wrong though, returns
None.
 
Raises: ???
availableComponents(self, name_wildcard='*', type_wildcard='*', activated=0)
Returns a list of ComponentInfos consisting of all Components known 
to manager.
 
Parameters:
- name_wildcard is a wildcard that the components name must match in 
order for its information to be returned
- type_wildcard is a wildcard that the components type must match in
order for its information to be returned.
- activated is a boolean value which specifies whether the search 
should be limited to components which have already been activated.
 
Returns: a list consisting of ComponentInfo structures for every
component manager knows of
 
Raises: ???
corbaObjectFromString(self, obj_uri)
Converts a string to a CORBA object reference.
 
Parameters:
- obj_uri is the address to the CORBA object
 
Return: a CORBA reference to obj_uri
 
Raises: ???
corbaObjectToString(self, comp_ref)
Converts a CORBA object its string representation.
 
Parameters: comp_ref is a reference to the CORBA object.
 
Return: the string representation (an IOR)
 
Raises: ???
findComponents(self, curl_wildcard='*', type_wildcard='*', activated=0)
Finds components by their instance name and/or by their type.
 
    Wildcards can be used for the curl and type.
    This method returns a possibly empty array of component curls; 
    for each curl, you may use getComponent to obtain the reference.
 
Parameters:
- name_wildcard (None is understood as "*")
- type_wildcard (None is understood as "*")
- activated is a boolean value which specifies whether the search 
should be limited to components which have already been activated.
 
Return: the curls of the component(s) that match the search.
 
Raises: ???
forceReleaseComponent(self, comp_name)
Forcefully releases the component defined by comp_name.
 
Parameter: comp_name is the name of the component to be released.
 
Returns: The number of objects still attached to the released component
 
Raises: Nothing
getCDBElement(self, record_name, ele_name)
This method returns all of the attributes in the form of a dictionary
for a given XML element within an XML file.
 
Parameters:
- record_name is the name of the XML file (e.g., "alma/MOUNT1")
- ele_name is the name of the element (e.g, "MOUNT/actAz")
- element_name is the name of the element (e.g, "MOUNT/actAz",
  where acsAz is an XML element contianing all attributes
  representing the characteristics of a BACI property).
 
Return: a dictionary
 
Raises: ???
getCDBRecord(self, record_name)
Returns the stringified version of an XML record in the ACS
configuration database defined by record_name.
 
Parameters:
- record_name is the full name of an XML record in the CDB.  An
example would be "alma/MOUNT1".
 
Return: the stringified XML record 
 
Raises: ???
getCollocatedComp(self, comp_spec, mark_as_default, target_comp)
Activation of a component so that it runs in the same process as
another given component.
 
Parameters:
- comp_spec (maci.ComponentSpec) Component to be obtained.
- mark_as_default (bool) Mark component as default component of its type
- target_comp Name of the target component (where to activate component)
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises:
- IncompleteComponentSpec
- InvalidComponentSpec
- ComponentSpecIncompatibleWithActiveComponent
getComponent(self, comp_name=None, activate=1, comp_idl_type=None, comp_code=None, container_name=None, is_dynamic=0)
NOTE: all keyword parameters with the exception of comp_name are
deprecated!
 
Get a component reference from the Manager.
 
This seemingly simple method is actually quite complicated. First, its
important to note that this method narrows the reference for the
developer and even imports the proper IDL Python stub. Under certain
circumstances though, the IDL Python stub may NOT exist in the correct
place which has led some developers to believe this method was broken
in the past. So if you see an error message beginning with
"Unable to import...", please check that you really CAN import the
CORBA stubs for the component you are trying to access using the
infamous "python -i" command.
 
The next important thing to realize is this method does not just
retrieve named components as its own name implies - based on the
parameters passed it could return default and dynamic components
also.
 
Parameters:
- name is the components name. If not None and the rest of the
default parameters are left as-is, this is assumed to be a static
component.
- activate tells manager whether the component should be activated
if it has not already been instantiated. Not too useful.
- comp_idl_type is the interface repository IDL location of the
component. If not None and the rest of the default parameters are
left as-is, it is assumed the developer wants a default component.
- comp_code is a shared library implementing component. If not
None, it is assumed the developer wants a dynamic component.
- container_name is the name of the container to activate component.
If not None, it is assumed the developer wants a dynamic component.
- is_dynamic states whether a component should be retrieved as
default or dynamic. In simple terms, when this parameter and
comp_idl_type are the only params that have been changed from their
original values, this is the difference between retrieving a reference
to a dynamic component or a default component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getComponentNonSticky(self, comp_name)
Gets the component in a non stick way.
The comp_name is a name of the component.
 
Parameters:
- comp_name is the name of the component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getContName(self)
Returns our container name.
 
Parameters: None
 
Return: name of the container the component was started by.
 
Raises: Nothing
getDefaultComponent(self, comp_type)
Gets the default component specified by the component type.
The type is the IDL type, such as "IDL:alma/PS/PowerSupply:1.0"
 
Parameters:
- comp_type is the interface repository IDL location of the
component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getDynamicComponent(self, name, comp_type, code, container)
Gets a component whose instance is not registered in the CDB 
at deployment time.
 
Parameters:
- name is the components name in string format
- comp_type is the interface repository IDL location of the component
- code is a shared library implementing component
- container is the name of the container to activate component.
 
Returns: a narrowed reference to the component or None if
that reference cannot be obtained.
 
Raises: CannotGetComponentExImpl if the component stubs cannot be loaded
        or found
getLogger(self)
Returns the component/client logger.
 
Parameters: None
 
Return: a logger
 
Raises: Nothing
getName(self)
Returns our name.
 
Parameters: None
 
Return: name of the component or client derived from ContainerServices.
 
Raises: Nothing
getThread(self, target, name, args=None, kwargs=None)
This method returns a Python threading.Thread object.
 
Parameters:
- target callable object to be invoked by the run() method
- name the thread name. Must be unique
- args is the argument tuple for the target invocation. Defaults to ()
- kwargs is a dictionary of keyword arguments for the target
invocation. Defaults to {}
 
Return: a threading.Thread object
 
Raises: ???
makeCompImmortal(self, comp_name, state)
Change mortality state of a component.
Compnent must be already active.
The caller must be owner of the component or have administator rights.
 
Parameters:
- comp_name name of the component
- state new mortality state
 
Returns: None
 
Raises: ???
releaseComponent(self, comp_name)
Release the component defined by comp_name.
 
Parameter: comp_name is the name of the component to be released.
 
Returns: The number of objects still attached to the released component
 
Raises: Nothing
restartComp(self, comp_name)
Restarts a component.
 
Parameters:
- comp_name name of the component
 
Returns: Reference to the restarted component.
 
Raises: ???
setAll(self, name, token, handle, activate_offshoot_method, contname=None)
This method should only be invoked by the container and provides the
component with all container services. DO NOT INVOKE FROM YOUR CODE!!!

 
class AdminConsumer(Acspy.Nc.Consumer.Consumer)
    This is a high-level consumer designed to process each and every event
from a given channel.  Each time an event is received, a formatted string
is sent to any registered callbacks using the working method.
 
 
Method resolution order:
AdminConsumer
Acspy.Nc.Consumer.Consumer
CosNotifyComm__POA.StructuredPushConsumer
CosNotifyComm__POA.NotifyPublish
omniORB.PortableServer.Servant
Acspy.Nc.CommonNC.CommonNC

Methods defined here:
__init__(self, channelName)
Constructor.
 
Handles absolutely everything. Once the constructor has been called,
there is absolutely nothing for the developer to do other than let
it run.
 
Parameters:
- channelName is the name of the channel to connect to
 
Raises: ???
push_structured_event(self, event)
CORBA method that is invoked by suppliers. push_structured_event is overriden
instead of processEvent because there's all sorts of good info to be obtained
from the entire StructuredEvent.
 
Parameters: event is a CosNotification.StructuredEvent
 
Returns: Nothing
 
Raises: ???

Methods inherited from Acspy.Nc.Consumer.Consumer:
addFilter(self, type_of_event, filter_exp)
add a filter.
 
Parameters:
- type_of_event is the actual Python class for the IDL struct.
- filter_exp is an EXTENDED_TCL string.
 
Returns: The ID of the newly created filter (positive integer?)
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
addSubscription(self, name, handler_function=None)
add a subscription to a given type.
 
Parameters
- name is the actual Python class for the IDL struct.
- handler_function If a structured event is received and the
registerHandler method has been defined on that SEs type_name, the
handler_function must be able to process filterable_data[0].value.value().
In other words every time an event of this nature is received, the
Consumer object will first try to invoke the handler_function
using the REAL object extracted from the CORBA Any in the structured
event located at the the first position of the filterable_data list.
IF THIS FAILS, the Consumer simply passes the event to the
processEvent(...) method which will have hopefully been overriden by
the developer.
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
consumerReady(self)
Consumer can now begin receiving events after invoking consumerReady.
 
Parameters: None
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
disconnect(self)
Consumer client must call this to disconnect from notification channel.
Once disconnect has been called, the Consumer object should be treated
as if it has been deleted.
 
Parameters: None
 
Returns: Nothing
 
Raises: Nothing
disconnect_structured_push_consumer(self)
Called by a supplier to inform this consumer it is disconnecting from
the channel. Developer code must never call this.
 
Parameters: None
 
Returns: Nothing
 
Raises: Nothing
getFilterLanguage(self)
This method returns a constant character pointer to the type of filter
constraint language to be used for filtering events which is normally
equivalent to acsnc::FILTER_LANGUAGE_NAME. Override to change this
behavior.
 
Parameters: None
 
Returns: string
 
Raises: nothing
initCORBA(self)
Handles all the CORBA involved in creating a Consumer.
 
Parameters: None
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
offer_change(self, added, removed)
Called by a supplier to inform this consumer its offering a change in the
events in publishing. Developer code must never call this.
 
Parameters:
- added is a list of domain/type pairs a supplier will begin publishing
- removed is a list of domain/type pairs a supplier will stop
publishing
 
Returns: Nothing
 
Raises: Nothing
processEvent(self, type_name=None, event_name=None, corba_any=None, se=None)
Developer should override this method if handlers are not used.  It does
NOT narrow the corba_any for the developer as there is no guarantee the
correct Python CORBA stub module has been imported!
 
Parameters:
- type_name corresponds to the type_name field of a structured event (i.e.,
string)
- event_name is the event_name field of a structured event (i.e., string)
- corba_any is filterable_data[0].value (i.e., CORBA any).  Most
developers are only interested in this.
- se is the entire structured event.
 
Returns: Nothing
 
Raises: Developer is free to raise any exception.
removeFilter(self, filter_id)
remove a filter defined by filter_id.
 
Parameters: filter_id should be what is returned by the addFilter
method
 
Returns: 1 on success and 0 on failure.
 
Raises: Nothing
removeSubscription(self, name)
remove a subscription type.
 
Parameters: name is the actual Python class for the IDL struct.
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
resume(self)
Resume receiving structured events.
 
Parameters: None
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
suspend(self)
Stop receiving structured events.
 
Parameters: None
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures

Methods inherited from Acspy.Nc.CommonNC.CommonNC:
configAdminProps(self)
Configures the administrative properties for this channel.
 
Only useful if the channel has not been created yet and this particular
method is being overriden.
 
Parameters: None
 
Returns: A sequence of Administrative properties.
 
Raises: Nothing
configQofS(self)
Configures the quality of service properties for this channel.
 
Only useful if the channel has not been created yet and this particular
method is being overriden.
 
Parameters: None
 
Returns: A sequence of Quality of Service properties.
 
Raises: Nothing
createNotificationChannel(self)
Creates the notification channel.  Only to be called if it does not already
exist.
 
Parameters: None
 
Returns: Nothing
 
Raises: ACSErrTypeCommonImpl.CORBAProblemExImpl on critical failures
destroyNotificationChannel(self)
Destroys the channel and unregisters it from the naming service. ONLY 
USE THIS METHOD IF YOU KNOW FOR CERTAIN THERE IS ONLY ONE SUPPLIER FOR 
THE CHANNEL!!!  To be used with extreme caution. Likely to be removed with
future versions of ACS.
 
Parameters: None
 
Returns: 1 on success and 0 on failure
 
Raises: Nothing
getChannelDomain(self)
This method returns a constant character pointer to the notification channel
domain which is normally equivalent to acscommon::ALMADOMAIN. The sole
reason this method is provided is to accomodate subclasses which
subscribe/publish non-ICD style events (ACS archiving channel for example).
In that case, the developer would override this method.
 
Parameters: None
 
Returns: a constant string.
 
Raises: Nothing
getChannelKind(self)
This method returns a constant character pointer to the "kind" of
notification channel as registered with the naming service (i.e., the kind
field of a CosNaming.Name) which is normally equivalent to
acscommon::NC_KIND. The sole reason this method is provided is to accomodate
subclasses which subscribe/publish non-ICD style events (ACS archiving
channel for example).In that case, the developer would override this method.
 
Parameters: None
 
Returns:a constant string.
 
Raises: Nothing
getNotificationFactoryName(self)
This method returns the name of the notification service as registered
with the CORBA Naming Service.
 
Parameters: None
 
Returns: pointer to a constant string. Normally
acscommon::NOTIFICATION_FACTORY_NAME
 
Raises: Nothing
getNotificationFactoryNameForChannel(self, channel, domain=None)
This method returns the name of the notification service for the channel
or domain from the configuration information given in the CDB.
 
Parameters:
- channel is the channel name of the desired factory
- domain is the domain of the desired factory
 
Returns: string containing the factory name or None
 
Raises: Nothing

 
Functions
       
signalHandler(signum, frame)
 Method to handle signals and make sure everything is cleaned up properly.
 
Parameters:
- signum the signal number
- frame the frame object 
 
Returns: Nothing
 
Raises: ???
sleep(...)
sleep(seconds)
 
Delay execution for a given number of seconds.  The argument may be
a floating point number for subsecond precision.
start_new_thread(...)
start_new_thread(function, args[, kwargs])
(start_new() is an obsolete synonym)
 
Start a new thread and return its identifier.  The thread will call the
function with positional arguments from the tuple args and keyword arguments
taken from the optional dictionary kwargs.  The thread exits when the
function returns; the return value is ignored.  The thread will also exit
when the function raises an unhandled exception; a stack trace will be
printed unless the exception is SystemExit.

 
Data
        CALLBACKS = []
CHANNEL = 'CHANNEL'
CONSUMER = 'CONSUMER'
EVENT_CACHE = {}
Pmw = <Pmw.Pmw_1_2.lib.PmwLoader.PmwLoader instance at 0xb79103ec>
__version__ = '$Id: ACSEventAdmin.py,v 1.11 2006/12/22 23:34:43 sharring Exp $'